{% macro search(request, total_records, fr_date='', to_date='') -%}
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
    <link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet" />
    <link href="{{ request.url_for('static', path='/admin/calendar_style.css') }}" rel="stylesheet" />
    <script>
    jQuery(function($){
        $.datepicker.regional["ko"] = {
            closeText: "关闭",
            prevText: "以前的交付",
            nextText: "下个月",
            currentText: "今天",
            monthNames: ["1月份(JAN)","2月份(FEB)","3月份(MAR)","4月份(APR)","5月份(MAY)","6月份(JUN)", "7月份(JUL)","8月份(AUG)","9月份(SEP)","10月份(OCT)","11月份(NOV)","12月份(DEC)"],
            monthNamesShort: ["1月份","2月份","3月份","4月份","5月份","6月份", "7月份","8月份","9月份","10月份","11月份","12月份"],
            dayNames: ["工作","月份","高大","编号","颈部","黄金","脚趾"],
            dayNamesShort: ["工作","月份","高大","编号","颈部","黄金","脚趾"],
            dayNamesMin: ["工作","月份","高大","编号","颈部","黄金","脚趾"],
            weekHeader: "Wk",
            dateFormat: "yymmdd",
            firstDay: 0,
            isRTL: false,
            showMonthAfterYear: true,
            yearSuffix: ""
        };
        $.datepicker.setDefaults($.datepicker.regional["ko"]);
    });
    </script>
    <form name="fvisit" id="fvisit" class="local_sch03 local_sch" method="get">
        {% if request.path == '/admin/visit_list' %}
            <span class="btn_ov01">
                <span class="ov_txt">已满 </span>
                <span class="ov_txt">已满 </span>
                <span class="ov_num"> {{ total_records }} 枪 </span>
            </span>
        {% endif %}
        <div class="sch_last">
            <strong>按期间搜索</strong>
            <input type="text" name="fr_date" value="{{ request.query_params.get('fr_date', '') }}" id="fr_date" class="frm_input" size="11" maxlength="10">
            <label for="fr_date" class="blind">开始日期</label>
            ~
            <input type="text" name="to_date" value="{{ request.query_params.get('to_date', '') }}" id="to_date" class="frm_input" size="11" maxlength="10">
            <label for="to_date" class="blind">一天结束</label>
            <input type="submit" value="搜索" class="btn_submit">
        </div>
    </form>

    <script>
        $(function(){
            $("#fr_date, #to_date").datepicker({
                changeMonth: true,
                changeYear: true,
                dateFormat: "yy-mm-dd",
                showButtonPanel: true,
                yearRange: "c-99:c+99",
                maxDate: "+0d"
            });
        });
        
        function fvisit_submit(act)
        {
            var f = document.fvisit;
            f.action = act;
            f.submit();
        }
    </script>
{%- endmacro %}

{% macro anchor(type, fr_date='', to_date='') -%}
    <ul class="anchor">
        <li {% if type == 'list' %}class="active"{% endif %}><a href="./visit_list?fr_date={{ fr_date }}&to_date={{ to_date }}">联系人</a></li>
        <li {% if type == 'domain' %}class="active"{% endif %}><a href="./visit_domain?fr_date={{ fr_date }}&to_date={{ to_date }}">域</a></li>
        <li {% if type == 'browser' %}class="active"{% endif %}><a href="./visit_browser?fr_date={{ fr_date }}&to_date={{ to_date }}">浏览器</a></li>
        <li {% if type == 'os' %}class="active"{% endif %}><a href="./visit_os?fr_date={{ fr_date }}&to_date={{ to_date }}">操作系统</a></li>
        <li {% if type == 'device' %}class="active"{% endif %}><a href="./visit_device?fr_date={{ fr_date }}&to_date={{ to_date }}">访问设备</a></li>
        <li {% if type == 'hour' %}class="active"{% endif %}><a href="./visit_hour?fr_date={{ fr_date }}&to_date={{ to_date }}">时间</a></li>
        <li {% if type == 'weekday' %}class="active"{% endif %}><a href="./visit_weekday?fr_date={{ fr_date }}&to_date={{ to_date }}">星期几</a></li>
        <li {% if type == 'date' %}class="active"{% endif %}><a href="./visit_date?fr_date={{ fr_date }}&to_date={{ to_date }}">工作</a></li>
        <li {% if type == 'month' %}class="active"{% endif %}><a href="./visit_month?fr_date={{ fr_date }}&to_date={{ to_date }}">月份</a></li>
        <li {% if type == 'year' %}class="active"{% endif %}><a href="./visit_year?fr_date={{ fr_date }}&to_date={{ to_date }}">年</a></li>
    </ul>
{%- endmacro %}